﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System;
using System.Runtime.Serialization;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using BrainTechLLC.ThreadSafeObjects;
using System.Xml.Serialization;
#if USE_HYPER
using Hyper.ComponentModel;
#endif

namespace BrainTechLLC
{
    [DataContract]
    [Serializable]
#if NO_SILVERLIGHT
    [Browsable(true)]
    [TypeConverter(typeof(ExpandableObjectConverter))]
    [EditorBrowsable(EditorBrowsableState.Always)]
#endif
    public class ItemCollection : AssociatedIDCollection
    {
        public ItemCollection() : base() { }
        public ItemCollection(long itemID) : base(itemID) { }

        public long _associatedWith;

        [NonSerialized, XmlIgnore]
        public bool _dirty;

#if NO_SILVERLIGHT
        [EditorBrowsable(EditorBrowsableState.Always)]
#endif
        [DataMember]
        [XmlIgnore]
        public long AssociatedWith
        {
            get { return _associatedWith; }
            set { _associatedWith = value; }
        }

        public void RemoveItem(long itemID)
        {
            Remove(itemID);
            _dirty = true;
        }

        public void AddItem(Item item)
        {
            item.Register();
            item.ParentItemCollection = this;
            Add(item.AssociatedID);
            _dirty = true;
        }

    }
}